import React from 'react';
import './index.scss';
import { Router, Route, Switch, Redirect } from 'react-router-dom';
import Test from './pages/Test';
import Loading from './pages/Loading';
import history from './utils/history';
import Search from './pages/Search';
import Result from './pages/Search/Result';
import Article from './pages/Article';
import Edit from './pages/Profile/Edit';
import Feedback from './pages/Profile/Feedback';
import Chat from './pages/Profile/Chat';
import AuthRoute from './components/AuthRoute';
const Login = React.lazy(() => import('@/pages/Login'));
const Layout = React.lazy(() => import('@/pages/Layout'));
const NotFound = React.lazy(() => import('@/pages/NotFound'));
export default function App() {
  return (
    <>
      <Router history={history}>
        <React.Suspense fallback={<Loading />}>
          <Switch>
            {/* 重定向 */}
            <Redirect from="/" to="/layout/home" exact></Redirect>
            <Route path="/login" component={Login} />
            <Route path="/layout" component={Layout} />
            <Route path="/test" component={Test} />
            {/* 不使用 tab 布局的界面 */}
            <Route path="/search/result" component={Result} />
            <Route path="/search" component={Search} />
            <Route path="/article/:id" component={Article} />
            <AuthRoute path="/profile/edit" component={Edit} />
            <AuthRoute path="/profile/feedback" component={Feedback} />
            <AuthRoute path="/profile/chat" component={Chat} />
            <Route component={NotFound} />
          </Switch>
        </React.Suspense>
      </Router>
    </>
  );
}
